package com.jblv.frame.common.enums;


/**
 * @author happyonion.yangtao
 * @version 1.0
 * @title ResultStateEnum
 * @projectName jblv-frame
 * @packageName com.jblv.common.type
 * @description 返回结果
 * @date Create at 2020/4/28 23:03
 * @since jdk1.8
 */

public enum ResultCodeEnum {
    // 操作成功
    SUCCESS_CODE(0000,"操作成功"),

    // 操作失败
    FAILD_OPERATE_CODE(5000,"操作失败"),
    // 请求超时
    ERROR_TIME_OUT_CODE(5001,"请求超时"),
    // 非法请求
    ERROR_INCORRECT_REQ_CODE(5002,"非法请求");

    private int code;

    private String message;


    ResultCodeEnum(int code,String message) {
        this.code = code;
        this.message = message;
    }


    public String getMessage() {
        return message;
    }

    public int getCode() {
        return code;
    }

    public static String getMessage(int code) {
        for (ResultCodeEnum type : values()) {
            if (type.getCode() == code) {
                return type.getMessage();
            }
        }
        return null;
    }

}
